﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace StoreHouseA
{
    using StoreHouseDataSetTableAdapters;

    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            action_customerc();
            this.Close();
        }

        private void action_customerc()
        {
            string in_old = comboBox1.Text;
            string in_code = comboBox3.Text;
            string in_new = comboBox2.Text;
            string in_level = comboBox4.Text;
            string in_location = textBox1.Text;
            decimal in_weight = numericUpDown1.Value;
            DateTime in_date = dateTimePicker1.Value.Date;
            DateTime in_date2 = dateTimePicker1.Value.Date.AddDays(1);
            string in_memo = textBox5.Text;
            string in_new_code = textBox4.Text;

            string in_oman = Program.oman;
            DateTime in_otime = DateTime.Now;

            tb_inoutTableAdapter a = new tb_inoutTableAdapter();
            a.Insert(in_code, in_level, in_old, in_location, 0, in_weight,
                in_date, "", "", in_new, "", "", in_memo, in_oman, in_otime);
            a.Insert(in_code, in_level, in_new, in_location, in_weight, 0,
                in_date2, "", "", in_old, "", "", in_memo, in_oman, in_otime);
            QueriesTableAdapter q = new QueriesTableAdapter();
            q.submit_deal(in_code, in_old, in_date);
            if (checkBox1.Checked)
            {
                a.Insert(in_code, in_level, in_new, in_location, 0, in_weight,
                    in_date, "", "", "", in_new_code, "", in_memo, in_oman, in_otime);
                q.submit_deal(in_code, in_new, in_date);
                a.Insert(in_code, in_level, in_old, in_location, in_weight, 0,
                    in_date2, "", "", "", in_code, "", in_memo, in_oman, in_otime);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked == true)
            {
                label11.Visible = true;
                textBox4.Visible = true;
            }
            else
            {
                label11.Visible = false;
                textBox4.Visible = false;
            }
        }

        private void Form4_Load(object sender, EventArgs e)
        {
            dateTimePicker1.Value = DateTime.Today;
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
        }

        private void textBox3_Click(object sender, EventArgs e)
        {
        }

        private void textBox4_Click(object sender, EventArgs e)
        {
        }
    }
}
